/*
 * EasyPlayerVideoPlayer.h
 *
 *  Created on: Apr 21, 2010
 *      Author: songyp
 */

#ifndef EASYPLAYERVIDEOPLAYER_H_
#define EASYPLAYERVIDEOPLAYER_H_

#include <videoplayer.h>
#include <coecntrl.h>

class CEasyPlayerVideoPlayer : public CActive,
							   public MVideoPlayerUtilityObserver
	{
public:
	static CEasyPlayerVideoPlayer * NewL( RWsSession& aWs,
			  CWsScreenDevice& aScreenDevice,
			  RWindowBase& aWindow,
			  const TRect& aScreenRect,
			  const TRect& aClipRect);
	static CEasyPlayerVideoPlayer * NewLC( RWsSession& aWs,
			  CWsScreenDevice& aScreenDevice,
			  RWindowBase& aWindow,
			  const TRect& aScreenRect,
			  const TRect& aClipRect );
	~CEasyPlayerVideoPlayer();
	
public:
	void StartPlayFileL( const TDesC & aFileName );
	
private:
	// from MVideoPlayerUtilityObserver
	void MvpuoOpenComplete( TInt aError );
	void MvpuoPrepareComplete( TInt aError );
	void MvpuoFrameReady( CFbsBitmap& aFrame, TInt aError );
	void MvpuoPlayComplete( TInt aError );
	void MvpuoEvent( const TMMFEvent& aEvent );
	
private:
	// from CActive
	void RunL();
	TInt RunError( TInt aError );
	void DoCancel();
	
private:
	CEasyPlayerVideoPlayer();
	void ConstructL( RWsSession& aWs,
			  CWsScreenDevice& aScreenDevice,
			  RWindowBase& aWindow,
			  const TRect& aScreenRect,
			  const TRect& aClipRect );
	
private:
	CVideoPlayerUtility * iPlayer;
	TInt iState;
	
private:
	enum EPlayerState
		{
		EIdle,
		EOpen,
		EPrepared,
		EFrameReady,
		EPlaying
		};
	};

#endif /* EASYPLAYERVIDEOPLAYER_H_ */
